package com.baidu.controller;

import com.baidu.pojo.Assess;
import com.baidu.pojo.Exhibition;
import com.baidu.pojo.Ticket;
import com.baidu.service.AssessService;
import com.baidu.service.ExhibitionService;
import com.baidu.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;
@Controller
@RequestMapping("/exhibition")
public class ExhibitionController {
    @Autowired
    private ExhibitionService exhibitionService;
    @Autowired
    private TicketService ticketService;
    @Autowired
    private AssessService assessService;
    @RequestMapping("/getExById")
    public String getExhibitionById(HttpSession session, Integer eid){
        System.out.println("eid:"+eid);
        Exhibition ex1 = exhibitionService.getExhibitionById(eid);
        List<Ticket> tick1 = ticketService.getAllTicket2(ex1.getEid());
        List<Assess> assess1 = assessService.getAssessByEid(eid);
        System.out.println("tick1"+tick1);
        session.setAttribute("ex1",ex1);
        session.setAttribute("tick1",tick1);
        session.setAttribute("assess1",assess1);
        return "buyTicket";
    }
    @RequestMapping("/getExhibition")
    @ResponseBody
    public List<Exhibition> getExhibition(String name){
        name = "%"+name+"%";
        List<Exhibition> ex = exhibitionService.getExhibition(name);

        return ex;
    }
}
